using System;
using System.Collections.Generic;
using System.Text;

namespace AI.AStar
{
    class AStarNode
    {
        IAStarNode m_GraphNode;
        AStarNode m_Parent;
        int m_GCost;
        int m_HCost;

        #region Constructors
        public AStarNode(IAStarNode node, AStarNode parent, int g, int h)
        {
            m_GraphNode = node;  m_Parent = parent; m_GCost = g; m_HCost = h;
        }
        #endregion

        #region Properties

        public IAStarNode NodeData
        {
            get { return m_GraphNode; }
            set { m_GraphNode = value; }
        }

        public AStarNode Parent
        {
            get { return m_Parent; }
            set { m_Parent = value; }
        }

        public int G
        {
            get { return m_GCost; }
            set { m_GCost = value; }
        }

        public int H
        {
            get { return m_HCost; }
            set { m_HCost = value; }
        }

        public int F
        {
            get { return m_HCost + m_GCost; }
        }
        #endregion

        #region Overrides
        public override bool Equals(object obj)
        {
            // to see if two AStarNodes are equal propagate
            // the test to the equality of their m_GraphNodes
            return m_GraphNode.Equals(((AStarNode)obj).NodeData);
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
        #endregion
    }
}
